package cn.smart.epic.modular.system.controller;

import cn.smart.epic.common.persistence.dao.UserMapper;
import cn.smart.epic.common.persistence.model.User;
import cn.smart.epic.modular.system.warpper.UserWarpper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @Auther Uncle_Z
 * @date 2017/9/9 23:49
 * @Email:2545375@qq.com
 * @Descrition
 * @since 1.0
 */

@Controller
@RequestMapping("/mgr")
public class UserMgController {


    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/index")
    public ModelAndView index(){
        ModelAndView view = new ModelAndView("/index.html");
        view.addObject("userList", Arrays.asList("aa","bb","cc","dd"));
        return view;
    }


    @RequestMapping("/list")
    @ResponseBody
    public Object list() {
        List<Map<String,Object>> result =userMapper.selectUsers(null,"","","",0);
        return new UserWarpper(result).warp();
    }

    @RequestMapping("/all")
    @ResponseBody
    public List<User> all(){
        List<User> all = userMapper.selectAll();
        return all;
    }

}
